home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
jpl_c.zip
/
RANDEXP.C
< prev
next >
Wrap
Text File
|
1986-05-18
|
1KB
|
33 lines
/* 1.0 01-22-85 */
/************************************************************************
* Robert C. Tausworthe *
* Jet Propulsion Laboratory *
* Pasadena, CA 91009 1985 *
************************************************************************
* Computes a sample value from an exponential distribution characterized
* by unit mean, i.e.,
*
* p(x) = exp(-x)
*
* The method is by inversion of the cumulative probability function. See
* also
*
* Knuth, D. E., FUNDAMENTAL ALGORITHMS, Vol II, "Seminumerical Algorithms"
* Addison-Wesley Pub. Co., page 128.
*
*/
#include "defs.h"
#include "stdtyp.h"
/************************************************************************/
double
randexp() /* Return an exponentially distributed random
value with unit mean. */
/*----------------------------------------------------------------------*/
{
double log(), random();
return (-log(random()));
}